package com.servlet.utils;

/**
 * @Title: ResponseVo
 * @Description:
 * @Auther: py
 * @Version: 1.0
 * @create 2023/12/22 15:24
 * 响应的实体
 */
public class ResponseVo<T> {

    private Integer status;   // 状态码

    private String msg;   // 响应的消息

    private T data;

    public static <T> ResponseVo<T> ok(String msg) {
         return new ResponseVo(200,msg);
    }

    public static <T> ResponseVo<T> ok(String msg,T data) {
        return new ResponseVo(200,msg,data);
    }

    public static <T> ResponseVo<T> error(Integer status,String msg) {
        return new ResponseVo(status,msg);
    }

    public static <T> ResponseVo<T> error(String msg) {
        return new ResponseVo(1000,msg);
    }

    public ResponseVo(Integer status, String msg) {
        this.status = status;
        this.msg = msg;
    }

    public ResponseVo(Integer status, String msg, T data) {
        this.status = status;
        this.msg = msg;
        this.data = data;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
